load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

filegroup(
    name = "testdata",
    srcs = glob(["testdata/**"]),
    visibility = ["//pkg/ccl/importerccl:__subpackages__"],
)

go_library(
    name = "importer",
    srcs = [
        "export_base.go",
        "exportcsv.go",
        "exportparquet.go",
        "import_job.go",
        "import_planning.go",
        "import_processor.go",
        "import_processor_planning.go",
        "import_table_creation.go",
        "import_type_resolver.go",
        "read_import_avro.go",
        "read_import_base.go",
        "read_import_csv.go",
        "read_import_mysql.go",
        "read_import_mysqlout.go",
        "read_import_pgcopy.go",
        "read_import_pgdump.go",
        "read_import_workload.go",
        "rollback_job.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/importer",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/cloud",
        "//pkg/cloud/cloudprivilege",
        "//pkg/clusterversion",
        "//pkg/col/coldata",
        "//pkg/docs",
        "//pkg/featureflag",
        "//pkg/jobs",
        "//pkg/jobs/ingeststopped",
        "//pkg/jobs/joberror",
        "//pkg/jobs/jobspb",
        "//pkg/jobs/jobsprofiler",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver/kvserverbase",
        "//pkg/kv/kvserver/protectedts",
        "//pkg/roachpb",
        "//pkg/security/username",
        "//pkg/server/telemetry",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/sql",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/catpb",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/catalog/dbdesc",
        "//pkg/sql/catalog/descidgen",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/descs",
        "//pkg/sql/catalog/ingesting",
        "//pkg/sql/catalog/resolver",
        "//pkg/sql/catalog/rewrite",
        "//pkg/sql/catalog/schemadesc",
        "//pkg/sql/catalog/schemaexpr",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/sql/catalog/typedesc",
        "//pkg/sql/execinfra",
        "//pkg/sql/execinfrapb",
        "//pkg/sql/exprutil",
        "//pkg/sql/faketreeeval",
        "//pkg/sql/flowinfra",
        "//pkg/sql/gcjob",
        "//pkg/sql/isql",
        "//pkg/sql/lexbase",
        "//pkg/sql/opt/memo",
        "//pkg/sql/parser",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/pgwire/pgnotice",
        "//pkg/sql/physicalplan",
        "//pkg/sql/privilege",
        "//pkg/sql/row",
        "//pkg/sql/rowenc",
        "//pkg/sql/rowexec",
        "//pkg/sql/sem/builtins",
        "//pkg/sql/sem/catconstants",
        "//pkg/sql/sem/catid",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/sql/sqlclustersettings",
        "//pkg/sql/sqlerrors",
        "//pkg/sql/sqltelemetry",
        "//pkg/sql/stats",
        "//pkg/sql/types",
        "//pkg/util",
        "//pkg/util/bufalloc",
        "//pkg/util/ctxgroup",
        "//pkg/util/encoding/csv",
        "//pkg/util/errorutil/unimplemented",
        "//pkg/util/hlc",
        "//pkg/util/humanizeutil",
        "//pkg/util/intsets",
        "//pkg/util/ioctx",
        "//pkg/util/log",
        "//pkg/util/log/eventpb",
        "//pkg/util/log/logutil",
        "//pkg/util/mon",
        "//pkg/util/parquet",
        "//pkg/util/protoutil",
        "//pkg/util/retry",
        "//pkg/util/syncutil",
        "//pkg/util/timeofday",
        "//pkg/util/timeutil",
        "//pkg/util/timeutil/pgdate",
        "//pkg/util/tracing",
        "//pkg/workload",
        "@com_github_cockroachdb_apd_v3//:apd",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_lib_pq//oid",
        "@com_github_linkedin_goavro_v2//:goavro",
        "@io_vitess_vitess//go/sqltypes",
        "@io_vitess_vitess//go/vt/sqlparser",
    ],
)

go_test(
    name = "importer_test",
    size = "large",
    srcs = [
        "bench_test.go",
        "client_import_test.go",
        "csv_internal_test.go",
        "csv_testdata_helpers_test.go",
        "exportcsv_test.go",
        "exportparquet_test.go",
        "import_csv_mark_redaction_test.go",
        "import_into_test.go",
        "import_mvcc_test.go",
        "import_processor_test.go",
        "import_stmt_test.go",
        "main_test.go",
        "mysql_testdata_helpers_test.go",
        "pg_testdata_helpers_test.go",
        "read_import_avro_logical_test.go",
        "read_import_avro_test.go",
        "read_import_base_test.go",
        "read_import_mysql_test.go",
        "read_import_pgdump_test.go",
        "testutils_test.go",
    ],
    data = glob(["testdata/**"]) + ["//c-deps:libgeos"],
    embed = [":importer"],
    exec_properties = select({
        "//build/toolchains:is_heavy": {"test.Pool": "large"},
        "//conditions:default": {"test.Pool": "default"},
    }),
    # It's a large test, so use 16 shards to run test cases.
    # See https://docs.bazel.build/versions/master/be/common-definitions.html#test.shard_count
    shard_count = 16,
    deps = [
        "//pkg/base",
        "//pkg/blobs",
        "//pkg/ccl",
        "//pkg/cloud",
        "//pkg/cloud/cloudpb",
        "//pkg/cloud/impl:cloudimpl",
        "//pkg/cloud/nodelocal",
        "//pkg/cloud/userfile",
        "//pkg/col/coldata",
        "//pkg/config",
        "//pkg/config/zonepb",
        "//pkg/jobs",
        "//pkg/jobs/jobspb",
        "//pkg/jobs/jobstest",
        "//pkg/keys",
        "//pkg/keyvisualizer",
        "//pkg/kv",
        "//pkg/kv/kvclient/kvcoord",
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver",
        "//pkg/kv/kvserver/kvserverbase",
        "//pkg/kv/kvserver/protectedts",
        "//pkg/multitenant/tenantcapabilities",
        "//pkg/roachpb",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/security/username",
        "//pkg/server",
        "//pkg/settings/cluster",
        "//pkg/sql",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/bootstrap",
        "//pkg/sql/catalog/catformat",
        "//pkg/sql/catalog/catpb",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/catalog/dbdesc",
        "//pkg/sql/catalog/descidgen",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/descs",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/sql/distsql",
        "//pkg/sql/execinfra",
        "//pkg/sql/execinfrapb",
        "//pkg/sql/flowinfra",
        "//pkg/sql/gcjob",
        "//pkg/sql/isql",
        "//pkg/sql/parser",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/randgen",
        "//pkg/sql/row",
        "//pkg/sql/rowenc",
        "//pkg/sql/rowexec",
        "//pkg/sql/sem/catconstants",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/sql/stats",
        "//pkg/sql/tests",
        "//pkg/sql/types",
        "//pkg/storage",
        "//pkg/testutils",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/jobutils",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/sqlutils",
        "//pkg/testutils/testcluster",
        "//pkg/util",
        "//pkg/util/ctxgroup",
        "//pkg/util/encoding/csv",
        "//pkg/util/envutil",
        "//pkg/util/hlc",
        "//pkg/util/ioctx",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/log/eventpb",
        "//pkg/util/mon",
        "//pkg/util/parquet",
        "//pkg/util/protoutil",
        "//pkg/util/randutil",
        "//pkg/util/retry",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/timeutil/pgdate",
        "//pkg/workload",
        "//pkg/workload/bank",
        "//pkg/workload/tpcc",
        "//pkg/workload/workloadsql",
        "@com_github_cockroachdb_cockroach_go_v2//crdb",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_gogo_protobuf//proto",
        "@com_github_jackc_pgconn//:pgconn",
        "@com_github_jackc_pgx_v4//:pgx",
        "@com_github_kr_pretty//:pretty",
        "@com_github_lib_pq//:pq",
        "@com_github_linkedin_goavro_v2//:goavro",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@io_vitess_vitess//go/vt/sqlparser",
    ],
)
